package cn.iocoder.yudao.module.crossborder.platform.api;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crossborder.platform.api.dto.PlatformDTO;
import cn.iocoder.yudao.module.crossborder.platform.api.dto.StoreDTO;
import cn.iocoder.yudao.module.crossborder.platform.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 平台管理 API 接口
 *
 * @author LHL
 */
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
@Tag(name = "RPC 服务 - 平台管理")
public interface PlatformApi {

    String PREFIX = ApiConstants.PREFIX + "/platform";

    @GetMapping(PREFIX + "/get")
    @Operation(summary = "获得平台")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    CommonResult<PlatformDTO> getPlatform(@RequestParam("id") @NotNull Long id);

    @GetMapping(PREFIX + "/list")
    @Operation(summary = "获得平台列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    CommonResult<List<PlatformDTO>> getPlatformList(@RequestParam("ids") @NotNull List<Long> ids);

    @PostMapping(PREFIX + "/create")
    @Operation(summary = "创建平台")
    CommonResult<Long> createPlatform(@RequestBody @Valid PlatformDTO platform);

    @GetMapping(PREFIX + "/store/get")
    @Operation(summary = "获得店铺")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    CommonResult<StoreDTO> getStore(@RequestParam("id") @NotNull Long id);

    @PostMapping(PREFIX + "/sync/product")
    @Operation(summary = "同步商品")
    @Parameter(name = "storeId", description = "店铺编号", required = true, example = "1024")
    @Parameter(name = "productId", description = "商品编号", required = true, example = "2048")
    CommonResult<Boolean> syncProduct(@RequestParam("storeId") @NotNull Long storeId,
                                     @RequestParam("productId") @NotNull Long productId);

    @PostMapping(PREFIX + "/sync/order")
    @Operation(summary = "同步订单")
    @Parameter(name = "storeId", description = "店铺编号", required = true, example = "1024")
    @Parameter(name = "orderId", description = "订单编号", required = true, example = "2048")
    CommonResult<Boolean> syncOrder(@RequestParam("storeId") @NotNull Long storeId,
                                   @RequestParam("orderId") @NotNull Long orderId);

    @PostMapping(PREFIX + "/sync/inventory")
    @Operation(summary = "同步库存")
    @Parameter(name = "storeId", description = "店铺编号", required = true, example = "1024")
    @Parameter(name = "productId", description = "商品编号", required = true, example = "2048")
    @Parameter(name = "quantity", description = "库存数量", required = true, example = "100")
    CommonResult<Boolean> syncInventory(@RequestParam("storeId") @NotNull Long storeId,
                                       @RequestParam("productId") @NotNull Long productId,
                                       @RequestParam("quantity") @NotNull Integer quantity);

}
